<form id="CalendarForm" name="CalendarForm" method="post" action="" runat="server">
<list:LIST id='List'>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center">
      <table border="2" cellspacing="2" cellpadding="2" width="98%" align="center">
		<tr>
          <td width="14%" bgcolor="#333366" class="calendarheader"><div align="center"><font color="#FFFFFF"><b>Sunday </b></font></div></td>
          <td width="14%" bgcolor="#333366" class="calendarheader"><div align="center"><font color="#FFFFFF"><b>Monday </b></font></div></td>
          <td width="14%" bgcolor="#333366" class="calendarheader"><div align="center"><font color="#FFFFFF"><b>Tuesday </b></font></div></td>
          <td width="14%" bgcolor="#333366" class="calendarheader"><div align="center"><font color="#FFFFFF"><b>Wednesday </b></font></div></td>
          <td width="14%" bgcolor="#333366" class="calendarheader"><div align="center"><font color="#FFFFFF"><b>Thursday </b></font></div></td>
          <td width="14%" bgcolor="#333366" class="calendarheader"><div align="center"><font color="#FFFFFF"><b>Friday </b></font></div></td>
          <td width="14%" bgcolor="#333366" class="calendarheader"><div align="center"><font color="#FFFFFF"><b>Saturday </b></font></div></td>
        </tr>


        <!--  -->
        <core:literal>
        <?php
          //get events for current month

          //draw calendar grid
          $selected_month = $root->get('month');
          $selected_year = $root->get('year');
          $firstDay = $root->get('firstDay');
          $numDays = $root->get('numDays');

          $prevmonth_year = $root->get('prevmonth_year');
          $prevyear_year = $root->get('prevyear_year');
          $prevmonth_month = $root->get('prevmonth_month');
          $prevyear_month = $root->get('prevyear_month');

          $nextmonth_year = $root->get('nextmonth_year');
          $nextyear_year = $root->get('nextyear_year');
          $nextmonth_month = $root->get('nextmonth_month');
          $nextyear_month = $root->get('nextyear_month');

          $current_month = $root->get('current_month');
          $current_year = $root->get('current_year');

          $prevmonth_name = $root->get('prevmonth_name');
          $nextmonth_name = $root->get('nextmonth_name');
          $month_name = $root->get('month_name');
          //print  $prevmonth_name ;

          $numWeeks = $numDays/7;
          $day=1; $week=0; $ev_num=0;
          $cur_day = (integer)date('d');
          $cur_month = (integer)date('m');
          $cur_year = (integer)date('Y');

          // pending events datasource
          $events_ds =& $root->children['CalendarForm']->children['List']->_datasource;

          //print_r($root);


          while($day<=$numDays)
          {
           $bgColor = ($week%2>0?"#FFFFFF":"#fdfda7");
           ?>
           <tr valign="middle" bgcolor="<?=$bgColor?>">
           <?php
             for($i=1;$i<=7;$i++)
             {
                $content="&nbsp;";
                $bgColor = ($week%2>0?"#FFFFFF":"#fdfda7");
                if(($week==0 && $i>$firstDay ) || ($week>0 && $day<=$numDays))
                {
                 if($cur_day == $day && $cur_month==$month && $cur_year==$year) $bgColor="#F4A460";
                 //show all events for current day
                 $events="";

                 $events_ds->reset();
                 //print_r( $events_ds );
                 while($events_ds->next()) {
                 	$event_date = $events_ds->get('event_date');
                 	$day_of_month = $events_ds->get('day_of_month');
                    $event_title = $events_ds->get('event_title');
                    $pending_event_id = $events_ds->get('pending_event_id');
                    if ($day_of_month == $day)
                      $events .= '<br>&gt;<a href="?pending_event_id='.$pending_event_id.'">'.$event_title.'</a>';
                 }

                 $title="";
                 //$content = "<a href=\"pub.event.php?pending_event_id=1\">".$day."</a>".
                 //"<font class=\"small\" size=\"1\">".$events."</font>";
                 $content = $day.'<span class="small">'.$events.'</span>';
                 $day++;
                }
           ?>
               <td height="100" valign="top" bgcolor="<?=$bgColor?>" >
                        <?=$content?>
               </td>
           <?php
           }
           ?> </tr> <?php
           $week++;
          }
      ?>
      </core:literal>

      <tr bgcolor="#333366" valign="middle">
          <td colspan="7" align="center">
            <table cellpadding="0" cellspacing="0" border="0" width="100%">
              <tr>
                <td bgcolor="#333366" valign="middle" align="center">
                <table align="center">
                <tr>
                 <td width="30%" align="center" colspan="3">
                   <font color="#FFFFFF">
                     <a style="color:yellow" href="?month=<?=$current_month?>&year=<?=$current_year?>">
                     <b>Today</b>
                     </a> &nbsp;
                   </font>
                </td>
                </tr>
                <tr>
                 <td width="30%" align="center">
                   <font color="#FFFFFF">
                    <a style="color:white" href="?month=<?php print $prevmonth_month?>&year=<?php print $prevmonth_year?>">
                    &lt; <core:literal> <?php echo $prevmonth_name?> </core:literal>
                    </a>
                   </font>
                </td>
                 <td width="30%" align="center">
                   <font color="#FFFFFF">
                       <a style="color:yellow" href="?month=<?php print $selected_month?>&year=<?php print $selected_year?>">
                       	 <core:literal> <?php print $month_name?> </core:literal>
                       </a> &nbsp;
                   </font>
                </td>
                 <td width="30%" align="center">
                   <font color="#FFFFFF">
                    <a style="color:white" href="?month=<?=$nextmonth_month?>&year=<?=$nextmonth_year?>">
                    <core:literal> <?=$nextmonth_name?> </core:literal> &gt;
                    </a>
                   </font>
                </td>
               </tr>
                 <td width="30%" align="center">
                   <font color="#FFFFFF">
                        <a style="color:white" href="?month=<?php print $prevyear_month?>&year=<?php print $prevyear_year?>">
                        &lt; <core:literal> <?php print $prevyear_year?> </core:literal>
                        </a>
                   </font>
                </td>
                 <td width="30%" align="center">
                   <font color="#FFFFFF">
		        		<a style="color:yellow" href="?month=1&year=<?=$selected_year?>">
		        		<core:literal> <?=$selected_year?> </core:literal>
		        		</a> &nbsp;
                   </font>
                </td>
                 <td width="30%" align="center">
                   <font color="#FFFFFF">
                        <a style="color:white" href="?month=<?php print $nextyear_month?>&year=<?php print $nextyear_year?>">
                        <core:literal> <?php print $nextyear_year?> </core:literal> &gt;
                        </a>
                   </font>
                </td>
                </tr>
                </table>
                </td>
                <td bgcolor="#333366" valign="middle" align="center">
                  <font color="#FFFFFF"> Select a month to display:<br>
                    <select name="month" id="month" runat="server">
                    </select>
                    <select name="year" id="year" runat="server">
                    </select>
                    <input type="image" name="go" src="images/go1.gif" align="absmiddle">
                    </font>
                </td>
              </tr>
            </table>
          </td>
        </tr>

        <!-- -->
      </table>

    </td>
  </tr>
</table>
</list:LIST>
</form>







